from texture import *
from numpy import *


# type_map = {
#     'float32': 'float',
#     'uint8': 'unsigned char',
#     'uint16': 'unsigned short',
#     'uint32': 'unsigned int',
#     'int8': 'char',
#     'int16': 'short',
#     'int32': 'int'
#     }
# 
# 
# type_map_rgba = {
#     'float32': 'float4',
#     'uint8': 'uchar4',
#     'uint16': 'ushort4',
#     'uint32': 'uint4',
#     'int8': 'char4',
#     'int16': 'short4',
#     'int32': 'int4'
#     }
    

class Dataset:
    # members: name, filename, dimension, num_channels, typename, size, texture

    def __init__(self, name, filename, typename, dimension, num_channels):
        self.name = name
        self.filename = filename
        self.typename = typename
        self.dimension = dimension
        self.num_channels = num_channels
        assert num_channels in [1, 4]
        assert dimension in [2, 3, 4]
    
    
    def load(self, mod):
        if self.dimension == 2 and self.num_channels == 1:
            texref, shape = load_data_2d(self.filename, self.name, mod)
        elif self.dimension == 2 and self.num_channels == 4:
            texref, shape = load_data_2d_rgba(self.filename, self.name, mod)
            shape = shape[:2]
        elif self.dimension == 3:
            texref, shape = load_data_3d(self.filename, self.name, mod)
        elif self.dimension == 4:
            texref, shape = load_data_4d(self.filename, self.name, mod)
        else:
            # TODO: support more shapes
            assert False
            
        self.texture = texref
        self.size = shape


